﻿using System;
using System.Collections.Generic;

using System.Text;

namespace Efficient.Domain
{
    public class KeywordField : ValueType<KeywordField>
    {
        private readonly string field = string.Empty;
        private readonly KeyMode matchMode = KeyMode.Contain;
        private readonly KeywordTable table;

        public KeywordTable Table
        {
            get { return table; }
        }

        public string Field
        {
            get { return field; }
        }
        
        public KeyMode MatchMode
        {
            get { return matchMode; }
        }

        public KeywordField(KeywordTable table, string field, KeyMode matchMode)
        {
            this.table = table;
            this.field = field;
            this.matchMode = matchMode;
        }


        public KeywordField(KeywordTable table, string field):this(table, field, KeyMode.Contain)
        {
        }

        public override int GetHashCode()
        {
            return this.field.GetHashCode() + table.GetHashCode();
        }

        protected override bool BusinessEquals(KeywordField entity)
        {
            return this.field.Equals(entity.field, StringComparison.OrdinalIgnoreCase) &&
                this.table.Equals(entity.table);
        }

        public override int CompareTo(KeywordField other)
        {
            return -1;
        }
    }
}
